package cn.wx;

import cn.binarywang.wx.miniapp.config.WxMaConfig;
import cn.binarywang.wx.miniapp.config.impl.WxMaDefaultConfigImpl;
import cn.wx.properties.MaProperties;
import org.apache.commons.lang3.StringUtils;

/**
 * WxMaConfig默认工厂类
 *
 * @author: sunshaoping
 * @date: Create by in 1:29 下午 2020/5/26
 * @see WxMaDefaultConfigImpl
 */
public class DefaultWxMaConfigFactory implements WxMaConfigFactory<MaProperties> {

    @Override
    public WxMaConfig create(MaProperties properties) {
        WxMaDefaultConfigImpl config = new WxMaDefaultConfigImpl();
        config.setAppid(StringUtils.trimToNull(properties.getAppId()));
        config.setSecret(StringUtils.trimToNull(properties.getSecret()));
        config.setAesKey(StringUtils.trimToNull(properties.getAesKey()));
        config.setToken(StringUtils.trimToNull(properties.getToken()));
        config.setMsgDataFormat(StringUtils.trimToNull(properties.getMsgDataFormat()));
        return config;
    }
}
